package com.godGuang.consultation.service.impl;

import com.godGuang.consultation.domain.Advisory;
import com.godGuang.consultation.domain.AdvisoryReq;
import com.godGuang.consultation.mapper.AdvisoryMapper;
import com.godGuang.consultation.service.AdvisoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @program: godGuang-medical
 * @description:
 * @author: godGuang
 * @create: 2024-01-15 15:36
 **/
@Service
public class AdvisoryServiceImpl implements AdvisoryService {
    @Autowired
    private AdvisoryMapper advisoryMapper;

    @Override
    public void insertAdvisory(Advisory advisory) {
        advisory.setAdvisoryTime(new Date());
        Integer byCountId = advisoryMapper.findByCountId(advisory.getDoctorId(), advisory.getUserId());
        if (byCountId!=0){
            throw new RuntimeException("您正在咨询该医生,请到当前咨询中查看");
        }
        advisoryMapper.insertAdvisory(advisory);
    }

    @Override
    public List<Advisory> list(AdvisoryReq advisoryReq) {
        return advisoryMapper.list(advisoryReq);
    }

    @Override
    public void updAdvisory(Advisory advisory) {
        advisoryMapper.updAdvisory(advisory);
    }
}

